package com.epoch.servicecourse.controller;

import com.epoch.servicecourse.bean.Course;
import com.epoch.servicecourse.service.CourseService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * @author admin
 */
@Slf4j
@RestController
public class CourseController {

    @Autowired
    private CourseService courseService;

    /**
     * 根据课程Id获取课程
     * @param courseId
     * @return
     */
    @ApiOperation(value = "课程版块")
    @GetMapping("epoch/course/{courseId}")
    public Course getCourseById(@PathVariable String courseId){
        return courseService.getCourseById(courseId);
    }

    /**
     * 获取指定类型的课程
     * @param map 包括课程类型以及课程个数
     * @return
     */
    @ApiOperation(value = "课程版块")
    @PostMapping("epoch/course/courseIdNum")
    public List<Course> getCourseByTypeId(@RequestBody HashMap<String,String> map){
        System.out.println("xxxx");
        return courseService.getCourseByTypeId(map);
    }
}
